﻿using QG.FrontDesk.BLL.IService;
using QG.FrontDesk.com.Models;
using QG.FrontDesk.Model;
using System.Web.Mvc;

namespace QG.FrontDesk.com.Controllers
{
    public class VerificationcodeController : Controller
    {
        private IVerificationCodeService verificationCodeService;
        public VerificationcodeController(IVerificationCodeService verificationCodeService)
        {
            this.verificationCodeService = verificationCodeService;
        }
        // GET: Verificationcode
        public ActionResult Index()
        {
            return View();
        }
        /// <summary>
        /// 发送验证码
        /// </summary>
        /// <param name="tel"></param>
        /// <returns></returns>
        public JsonResult SendCode(string tel)
        {
            ResponseResult result = new ResponseResult();
            result.success =  verificationCodeService.SendCode(tel);
            return Json(result);
        }
        /// <summary>
        /// 判断验证码可用
        /// </summary>
        /// <param name="verificationCode"></param>
        /// <returns></returns>
        public JsonResult ValidateCode(VerificationCode verificationCode)
        {

            ResponseResult result = new ResponseResult();
            result.success = verificationCodeService.QueryVerificationCode(verificationCode)>0;
            return Json(result);
        }


        
    }
}